import request from "@/request/api";
import axios from "axios";
//获取当前用户信息
export function getUserInfo() {
  return request({
    url: "/eam-service-auth/auth/getSsoLoginUserInfo.htm",
    method: "get",
  });
}
//获取单个用户基本信息(不包含权限信息)
export function getUserDataByAccount(account = "") {
  return request({
    url: "/eam-service-system/system/staff/getSingleUserInfo",
    method: "get",
    params: {
      account,
    },
  });
}
//获取当前用户信息
export function getStaffInfo(account = "") {
  return request({
    url: "/eam-service-system/system/staff/queryStaffInfo",
    method: "get",
    params: {
      account,
    },
  });
}
//获取菜单权限信息
export function getMenuInfo(systemCode = "") {
  return request({
    url: "/jurisdictionCommon/getPersonMenuData.htm",
    method: "post",
    params: {
      appCode: systemCode,
    },
  });
}

//操作记录分页查询
export function getOperatePageList(data) {
  return request({
    url: "/eam-common-web/log/page",
    method: "get",
    params: data,
  });
}

//获取操作记录
export function getOperateList(data) {
  return request({
    url: "/eam-common-web/log",
    method: "get",
    params: data,
  });
}
//新增操作记录
export function addOperateLog(data) {
  return request({
    url: "/eam-common-web/log",
    method: "post",
    data: data,
  });
}

//登录日志分页查询
export function getLoginPageList(data) {
  return request({
    url: "/eam-common-web/log/logLogin/page",
    method: "get",
    params: data,
  });
}

//获取字典数据
export function getDictTreeData(data) {
  return request({
    url: "/eam-service-system/sys/DataDictDetail/all",
    method: "get",
    params: data,
  });
}
//获取组织树列表
export function queryOrgTree(data) {
  return request({
    url: "/eam-service-system/system/org/queryOrgTree",
    method: "get",
    params: data,
  });
}

//查询公司列表
export function queryComList() {
  return request({
    url: "/common/queryComList.htm",
    method: "get",
  });
}

//获取组织树列表(权限下)
export function queryOrgTreeAuth(parentCode = "", appId = "AQGL") {
  return request({
    // url: '/jurisdictionCommon/getPersonOrgData.htm?parentCode=' + parentCode + '&appCode=' + appCode,
    url:
      "/common/queryUserOrgPermission.htm?parentCode=" +
      parentCode +
      "&appId=" +
      appId,
    method: "get",
  });
}

//获取组织用户信息
export function queryUserList(data) {
  return request({
    url: "/eam-service-system/system/staff/queryStaffListByOrg",
    method: "get",
    params: data,
  });
}
//查询组织列表
export function getOrgList(data) {
  return request({
    url: "/eam-service-system/system/org/queryOrgList",
    method: "get",
    params: data,
  });
}
//查询实名验证用户信息
export function queryRealNameUser(data = {}) {
  //仅查询在职人员
  data.workStatus = 1;
  return request({
    url: "/realName/queryList.htm",
    method: "post",
    params: data,
  });
}

//查询标段列表
export function queryBidList(data = {}) {
  return request({
    url: "/common/queryBidList.htm",
    method: "post",
    data: data,
  });
}

//查询标段列表(权限下)
export function queryBidListAuth(data = {}, appCode = "") {
  return request({
    url: "/jurisdictionCommon/queryPersonBidList.htm?appCode=" + appCode,
    method: "post",
    data: data,
  });
}

export function queryAreaList(data = {}) {
  return request({
    url: "/common/queryWorkAreaList.htm",
    method: "post",
    data: data,
  });
}
// 查询组织列表
export function queryOrgList(data = {}) {
  return request({
    url: "/common/queryOrgList.htm",
    method: "post",
    data: data,
  });
}
//获取版本配置项
export function getVersionApi(data) {
  return request({
    url: "eam-service-system/sys/ConfigType/getByClassifyCodeAndCode",
    method: "get",
    params: data,
  });
}

//查询设备台账树形结构
export function deviceTree() {
  return request({
    url: "/eam-service-device/equipment/getTree",
    method: "get",
  });
}
//获取设备预设参数值
export function getPresetParamsApi(data) {
  return request({
    url: "/eam-service-device/equipment/getGenericParams",
    method: "get",
    params: data,
  });
}
//查询设备分类树-全加载
export function deviceClassifyTree() {
  return request({
    url: "/eam-service-standard/deviceClassify/tree",
    method: "get",
  });
}
//查询设备分类列表
export function deviceClassifyList(data) {
  return request({
    url: "/eam-service-standard/deviceClassify/page",
    method: "get",
    params: data,
  });
}
//获取工作流操作界面
export function getWorkflow(data) {
  return request({
    url: "/eam-common-web/sys/Workflow/view",
    method: "get",
    params: data
  });
}
// //获取工作流操作界面
// export function getWorkflow(findId = "") {
//   return request({
//     url: "/eam-common-web/sys/Workflow/view",
//     method: "get",
//     params: {
//       findId,
//     },
//   });
// }
// //获取工作流初始操作界面
// export function getWorkflowInit(processCode = "") {
//   return request({
//     url: "/eam-common-web/sys/Workflow/viewInit",
//     method: "get",
//     params: {
//       processCode,
//     },
//   });
// }
//获取工作流界面（没有提交按钮）
export function getWorkflowOnly(findId = "") {
  return request({
    url: "/eam-common-web/sys/Workflow/viewOnly",
    method: "get",
    params: {
      findId,
    },
  });
}
//获取工作流历史记录
export function getWorkflowHistory(findId = "") {
  return request({
    url: "/eam-common-web/sys/Workflow/mobileHistory",
    method: "get",
    params: {
      findId,
    },
  });
}
//工作流办理接口
export function submitWorkflow(data) {
  return request({
    url: "/eam-common-web/sys/Workflow/submit",
    method: "post",
    data: data,
  });
}
//查询设备分类树-懒加载
export function lazyClassifyTree(parentId = "") {
  return request({
    url: "/eam-service-device/equipment/getTreeLazy",
    method: "get",
    params: {
      parentId,
    },
  });
}
//设置表格配置项
export function getTableConfigApi(data) {
  return request({
    url: "/eam-common-web/personalizedConfiguration/getList",
    method: "get",
    params: data,
  });
}

//获取表格配置项
export function setTableConfigApi(data) {
  return request({
    url: "/eam-common-web/personalizedConfiguration/save",
    method: "post",
    data: data,
  });
}
//获取表格配置项
export function deleteTableConfigApi(data) {
  return request({
    url: "/eam-common-web/personalizedConfiguration/deleteById",
    method: "get",
    params: data,
  });
}
/**附件信息 */
//附件列表查询
export function getAttachList(data) {
  return request({
    url: "/eam-common-web/attachment/attachmentList",
    params: data,
    method: "get",
  });
}
//附件上传接口
export function uploadAttach(data = {}, formdata = new FormData()) {
  return request({
    url: `/eam-common-web/attachment/appendAttachmentList`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    params: data,
    data: formdata,
  });
}
//附件上传接口
export function uploadAttachSingle(data = {}, formdata = new FormData()) {
  return request({
    url: `/eam-common-web/attachment/uploadSingle`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    params: data,
    data: formdata,
  });
}
//附件上传接口（删除原先的业务附件, 每次上传, 需上传所有的附件）
export function uploadFileApi(data = {}, formdata = new FormData()) {
  return request({
    url: `/eam-common-web/attachment/upload`,
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    params: data,
    data: formdata,
  });
}
//附件预览或下载
export function getFilesList(data = {}) {
  return request({
    url: `/eam-common-web/attachment/attachmentListByBusinessIds`,
    method: "get",
    params: data,
  });
}
export function downloadFile(data = {}) {
  return request({
    url: `/eam-common-web/attachment/preview`,
    method: "get",
    params: data,
  });
}

//删除单个附件通过文件id
export function deleteFiles(fileId = "") {
  return request({
    url: `/eam-common-web/attachment/delete`,
    method: "get",
    params: {
      fileId,
    },
  });
}
//删除附件通过多个业务id,业务类型
export function deleteFilesByIds(data) {
  return request({
    url: `/eam-common-web/attachment/deleteByBusinessIdsWithType`,
    method: "get",
    params: data,
  });
}
//删除附件通过业务id,业务类型
export function deleteFilesType(data) {
  return request({
    url: `/eam-common-web/attachment/deleteByBusinessIdWithType`,
    method: "get",
    params: data,
  });
}
//追加附件list,不会删除全部原来附件,根据deleteFileIds有需要的删除
export function deleteFilesList(data, filesId) {
  return request({
    url: `/eam-common-web/attachment/appendAttachmentList`,
    method: "post",
    params: data,
    data: filesId,
  });
}
//批量复制文件根据业务id
export function copySourcesToTargets(data) {
  return request({
    url: `/eam-common-web//attachment/copySourcesToTargets`,
    method: "put",
    data: data,
  });
}
//下载打印控件
export function downloadPrintSoftware(data = {}) {
  return request({
    url: `/eam-common-web/printConfig/downloadPrint`,
    method: "get",
    params: data,
    responseType: "blob",
  });
}
//创建签名文档
export function createSignFile(params, data) {
  return request({
    url: "/eam-common-web/ElectronicSignature/createByFile",
    method: "post",
    params: params,
    data: data,
  });
}
//创建签名合同
export function createSignContract(data) {
  return request({
    url: "/eam-common-web/ElectronicSignature/createByCategory",
    method: "get",
    params: data,
  });
}
//创建签名合同
export function updateUserPhone(data) {
  return request({
    url: '/eam-common-web/system/staff/updateUserSimple',
    method: 'get',
    params: data
  })
}
//获取岗位信息搜索
export function queryPostList(data) {
  return request({
    url: "/eam-service-system/post/queryList",
    method: "get",
    params: data,
  });
}
//工作流提交按钮打开弹窗显示下一步处理人接口
export function getNextHandler(data) {
  return request({
    url: "/eam-common-web/sys/Workflow/submitter",
    method: "post",
    data: data,
  });
}

//获取选人组件过滤后的处理人
export function getFilterMember(data) {
  return request({
    url: "/eam-common-web/sys/Workflow/handler",
    method: "post",
    data: data,
  });
}

// 工作关注
export function follow(data) {
  return request({
    url: "/eam-common-web/follow/addfollow",
    method: "post",
    data: data,
  });
}

// 取关
export function cancelfollow(data) {
  return request({
    url: "/eam-common-web/follow/cancelfollow",
    method: "post",
    data: data,
  });
}
// 获取关注列表
export function serchfollow(data) {
  return request({
    url: "/eam-common-web/follow/serchfollow",
    method: "post",
    data: data,
  });
}

// 查询关注
export function getfollow(data) {
  return request({
    url: "/eam-common-web/follow/getfollow",
    method: "post",
    data: data,
  });
}
// 传阅
export function transmit(data) {
  return request({
    url: "/eam-common-web/transmit/transmit",
    method: "post",
    data: data,
  });
}

// 分页查询消息主题表列表
export function queryMessageList(data) {
  return request({
    url: "/eam-common-web/messageTopic/queryPageList",
    method: "get",
    params: data,
  });
}
// 新增或修改消息主题表
export function insertOrUpdateMessage(data) {
  return request({
    url: "/eam-common-web/messageTopic/insertOrUpdate",
    method: "post",
    data: data,
  });
}
// id查询消息
export function queryByIdMessage(id = "") {
  return request({
    url: `/eam-common-web/messageTopic/queryById`,
    method: "get",
    params: {
      id,
    },
  });
}

// 删除信息
export function deleteByIdMessage(id = "") {
  return request({
    url: `/eam-common-web/messageTopic/deleteById`,
    method: "delete",
    params: {
      id,
    },
  });
}

// 通知记录
export function queryHistoryList(data) {
  return request({
    url: "/eam-common-web/messageHistory/queryPageList",
    method: "get",
    params: data,
  });
}

// 发送短信和企业微信
export function sendMessageToQywx({title, handler, notifyType = ["sms", "qywx"], topicCode = "order_topic"}) {
  return request({
    url: "/eam-common-web/messageUtil/sendMessage",
    method: "post",
    data: {
      args: [title],
      handler,
      notifyType,
      topicCode
    }
  });
}

